package com.lottery.ruok.lottrey.ui.component;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.lottery.ruok.lottrey.R;
import com.lottery.ruok.lottrey.utils.StringUtils;

import butterknife.BindView;
/*
* 购彩详情页头部自定义view
*
* */
public class BuyLotteryTopView extends BaseRelativeLayout implements View.OnClickListener {
    @BindView(R.id.include_back)
    ImageView includeBack;
    @BindView(R.id.include_title)
    TextView includeTitle;
    @BindView(R.id.include_note)
    LinearLayout includeNote;
    @BindView(R.id.include_trend)
    LinearLayout includeTrend;
    @BindView(R.id.include_rule)
    LinearLayout includeRule;
    private BuyLotteryTopViewListener mBuyLotteryTopViewListener;

    public BuyLotteryTopView(Context context) {
        super(context);
    }

    public BuyLotteryTopView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public BuyLotteryTopView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void init(Context context, AttributeSet attrs, int defStyleAttr) {
        setContentView(R.layout.include_top);
    }

    @Override
    protected void initView(Context context) {
        includeBack.setOnClickListener(this);
        includeTitle.setOnClickListener(this);
        includeNote.setOnClickListener(this);
        includeTrend.setOnClickListener(this);
        includeRule.setOnClickListener(this);
    }

    @Override
    protected void load(Context context) {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            //1back，2彩票名称，3投注记录，4走势，5规则
            case R.id.include_back:
                if (mBuyLotteryTopViewListener != null) {
                    mBuyLotteryTopViewListener.tabOnClick(1);
                }
                break;
            case R.id.include_title:
                if (mBuyLotteryTopViewListener != null) {
                    mBuyLotteryTopViewListener.tabOnClick(2);
                }
                break;
            case R.id.include_note:
                if (mBuyLotteryTopViewListener != null) {
                    mBuyLotteryTopViewListener.tabOnClick(3);
                }
                break;
            case R.id.include_trend:
                if (mBuyLotteryTopViewListener != null) {
                    mBuyLotteryTopViewListener.tabOnClick(4);
                }
                break;
            case R.id.include_rule:
                if (mBuyLotteryTopViewListener != null) {
                    mBuyLotteryTopViewListener.tabOnClick(5);
                }
                break;
        }
    }

    public interface BuyLotteryTopViewListener {
        //1back，2彩票名称，3投注记录，4走势，5规则
        void tabOnClick(int type);
    }

    public void setBuyLotteryTopViewListener(BuyLotteryTopViewListener buyLotteryTopViewListener) {
        mBuyLotteryTopViewListener = buyLotteryTopViewListener;
    }
    public void setLotteryName(String name){
        if (StringUtils.isNotEmpty(name)){
            includeTitle.setText(name);
        }

    }
}
